<!--回弹业务数据字典---回弹仪器设备管理---查看-->
<template>
  <div class="department" id="department">
    <!-- 右侧 -->
    <div class="department_right">
      <!-- 顶部导航栏 -->
      <div class="mechanism_nav">
        <!-- 左侧 -->
        <div class="mechanism_nav_left">
          <el-radio-group
            v-model="radio"
            size="small"
            @change="modelType($event)"
          >
            <el-radio-button label="待办"></el-radio-button>
            <el-radio-button label="已办"></el-radio-button>
          </el-radio-group>
        </div>
        <!-- 顶部按钮 -->
        <div class="print">
          <div class="printTable">
            <el-button
              type="primary"
              icon="el-icon-refresh"
              size="small"
              @click="yj_searchForm(getList)"
            ></el-button>
            <!-- "fStatus": "编辑中",  //状态：编辑中，签认中，已打回，已完成  只有编辑中的状态可以进行修改提交删除， 已打回状态只能进行修改提交无法删除 -->
            <!-- (row.fStatus == '编辑中' || row.fStatus == '已打回')&& -->

            <el-button
              type="primary"
              icon="el-icon-edit"
              size="small"
              v-if="getList.modelType == '0' && yj_add == true"
              @click="edit('新增')"
              >新增</el-button
            >
            <el-button
              type="primary"
              icon="el-icon-edit"
              size="small"
              v-if="
                getList.modelType == '0' &&
                yj_edit == true &&
                (row.fstatus == '编辑中' || row.fstatus == '已打回')
              "
              @click="edit('编辑')"
              >编辑</el-button
            >
            <el-button
              type="primary"
              icon="el-icon-circle-check"
              size="small"
              v-if="
                getList.modelType == '0' &&
                yj_submit == true &&
                (row.fstatus == '编辑中' || row.fstatus == '已打回')
              "
              @click="SubmitText(fId)"
              >提交</el-button
            >
            <el-button
              type="primary"
              icon="el-icon-circle-check"
              size="small"
              v-if="yj_examine == true && row.fstatus == '签认中'"
              @click="edit('审核')"
              >审核</el-button
            >
            <el-button
              type="primary"
              icon="el-icon-delete"
              size="small"
              v-if="
                getList.modelType == '0' &&
                yj_delete == true &&
                row.fstatus == '编辑中'
              "
              @click="rowDelete(fId)"
              >删除</el-button
            >
          </div>
        </div>
      </div>

      <!-- 表格 -->
      <div class="text_table">
        <tableData
          :height="navigatepageNums > 1 ? 'calc(100% - 50px)' : '100%'"
          :config="table_config"
          :dataList="tableData"
          :loading="loading"
          @selection-change="selectionChange"
          @sort-change="sortChange"
          @click-change="rowChange"
          @ClickOnLine="yj_viewForm"
          :page="getList.page"
          :pageSize="getList.pageSize"
        />
        <pagination
          v-if="navigatepageNums > 1"
          :info="queryCriteriaData"
          :treelength="treelength"
          :total="queryCriteriaData.total"
          :pageNum.sync="getList.page"
          :limit.sync="getList.pageSize"
          @pagination="yj_searchForm(getList)"
        />
      </div>
      <!--班组首件信息弹框-->
      <div class="Control-1 mechanism_dialogS closure">
        <el-dialog
          :title="dialogTitle"
          :modal-append-to-body="false"
          v-dialogDrag
          :visible.sync="dialogEditVisible"
          v-loading="loadingEditDialog"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div
            class="dialogBody common"
            :style="{ height: '650px' }"
            style="overflow: hidden"
          >
            <div style="overflow-y: auto; margin-bottom: 20px">
              <div class="baseTitle" v-if="Sign != '审核' || Sign == '查看'">
                班组首件信息
              </div>
              <div
                class="publicForm"
                style="height: 300px"
                v-if="Sign != '审核' || Sign == '查看'"
              >
                <div class="publicFormBox">
                  <publicForm
                    ref="publicForm0"
                    lableWidth="165px"
                    :formObj="FromShowTop"
                    :formData="formData"
                    @inputChange="inputChange"
                    :timestamp="formData.fDirectorreportfile"
                    :fileList="fSourcefileList"
                    @delteFile="delteFile"
                    @inputFocus="inputFocus"
                  >
                  </publicForm>
                </div>
                <div class="publicFormBox">
                  <publicForm
                    ref="publicForm1"
                    lableWidth="165px"
                    :formObj="FromShowBottom"
                    :formData="formData"
                    @inputChange="inputChange"
                    :timestamp="formData.fQualityimagefile"
                    :fileList="fSourcefileList1"
                    @delteFile="delteFile1"
                    @inputFocus="inputFocus"
                    @inputBlur="inputBlur"
                    @clickDialog="clickDialog"
                  >
                  </publicForm>
                </div>
              </div>

              <div class="baseTitle" v-if="Sign == '查看' || Sign == '审核'">
                签认
              </div>
              <div
                class="publicForm"
                style="height: 80px"
                v-if="Sign == '查看' || Sign == '审核'"
              >
                <publicForm
                  ref="publicForm2"
                  lableWidth="160px"
                  :formObj="FromShow1"
                  :formData="formData"
                  @selectChange="selectChange"
                >
                </publicForm>
              </div>

              <div style="height: 50px"></div>
            </div>
          </div>
          <div class="newlyAdded_btn" v-if="btnShow">
            <el-button
              type="primary"
              @click="yj_saveForm(0)"
              v-if="Sign != '审核'"
              >保存</el-button
            >
            <el-button
              type="primary"
              @click="yj_saveForm(1)"
              v-if="Sign == '审核'"
              >签认</el-button
            >
            <el-button type="warning" @click="dialogEditVisible = false"
              >关闭</el-button
            >
          </div>
        </el-dialog>
      </div>
      <!-- 网格弹框列表 -->
      <div class="Control-1 mechanism_dialogS closure">
        <el-dialog
          title="首件工程隶属质量网格列表"
          :modal-append-to-body="false"
          v-dialogDrag
          :visible.sync="dialogEditVisibleGrid"
          v-loading="loadingEditDialogGrid"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div
            class="dialogBody common"
            :style="{ height: '650px' }"
            style="overflow: hidden"
          >
            <div
              style="
                overflow-y: auto;
                margin-bottom: 20px;
                height: calc(100% - 40px);
              "
            >
              <tableData
                :height="
                  navigatepageNumsGrid > 1 ? 'calc(100% - 50px)' : '100%'
                "
                :config="table_configGrid"
                :dataList="tableDataGrid"
                @selection-change="selectionChange"
                @sort-change="sortChange"
                @click-change="rowChangeGrid"
                :page="getList.page"
                :pageSize="getList.pageSize"
              />
              <pagination
                v-if="navigatepageNumsGrid > 1"
                :info="queryCriteriaDataGrid"
                :treelength="treelength"
                :total="queryCriteriaDataGrid.total"
                :pageNum.sync="getListGrid.page"
                :limit.sync="getListGrid.pageSize"
                @pagination="yj_searchFormGrid(getListGrid)"
              />
            </div>
            <div class="newlyAdded_btn">
              <el-button type="primary" @click="yj_saveFormGrid()"
                >保存</el-button
              >
              <el-button type="warning" @click="dialogEditVisibleGrid = false"
                >关闭</el-button
              >
            </div>
          </div>
        </el-dialog>
      </div>
      <!-- 根据组织机构树选人 -->
      <div class="Control-1 mechanism_dialogS closure">
        <el-dialog
          :title="candidate"
          :modal-append-to-body="false"
          v-dialogDrag
          :visible.sync="dialogEditVisibleTree"
          v-loading="loadingEditDialogTree"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div
            class="dialogBody common"
            :style="{ height: '650px' }"
            style="overflow: hidden; width: 100%"
          >
            <div style="margin-bottom: 20px; height: 100%; width: 100%">
              <div
                class="publicForm addMemberCheckBox"
                style="height: calc(100% - 40px); overflow-y: auto; width: 100%"
              >
                <div class="addMemberCheckTree">
                  <div class="companyBox">
                    <el-tree
                      :data="companyInfo"
                      :props="defaultProps"
                      @node-click="selectCompany"
                      :highlight-current="highlightBd"
                    ></el-tree>
                  </div>
                  <div class="departmentBox">
                    <div
                      class="departmentTitle"
                      v-for="(item, index) in departmentList"
                      :key="index"
                      @click="seletDepartment(item, index)"
                    >
                      <a
                        href="javascript:;"
                        :class="num === item.fDepartmentId ? 'activetext' : ''"
                        :title="item.fShortName"
                      >
                        {{ item.fShortName }}</a
                      >
                    </div>
                  </div>
                </div>

                <div class="addMemberCheckLeft">
                  <el-radio-group
                    v-model="checkboxGroup1"
                    @change="selectRealname($event, personList)"
                  >
                    <el-radio-button
                      v-for="item in personList"
                      :label="item.fUserid"
                      :key="item.fUserid"
                      :value="item.fRealname"
                    >
                      <div class="addMemberCheck">
                        <div class="MemberIcon">
                          <img :src="item.fGender == 0 ? girls : boys" alt="" />
                        </div>
                        <div class="MemberDetailInfos">
                          <div class="name">{{ item.fRealname }}</div>
                          <div class="hostName">{{ item.fDepartmentName }}</div>
                          <div class="hostName">{{ item.fAccount }}</div>
                        </div>
                      </div>
                    </el-radio-button>
                  </el-radio-group>
                </div>
              </div>
            </div>
          </div>
          <div class="newlyAdded_btn" v-if="btnShow">
            <el-button type="primary" @click="submitMember()">保存</el-button>
            <el-button type="warning" @click="dialogEditVisibleTree = false"
              >关闭</el-button
            >
          </div>
        </el-dialog>
      </div>
      <!-- 工程划分弹框 -->
      <div class="Control-1 mechanism_dialog ghgh">
        <el-dialog
          :close-on-click-modal="false"
          title="标段工程划分"
          v-dialogDrag
          :visible.sync="dialogTableVisibleDivide"
          v-loading="loadingDialogDivide"
          element-loading-text="拼命加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)"
        >
          <div
            class="dialogBody common"
            :style="{ height: '650px' }"
            style="overflow: hidden; white: 100%"
          >
            <!-- 工程划分列表 -->
            <div class="text_table">
              <el-table
                ref="multipleTable"
                :data="tableData5"
                style="width: 100%"
                :height="navigatepageNums > 1 ? 'calc(100% - 20px)' : '100%'"
                border
                default-expand-all
                :tree-props="{
                  children: 'children',
                  hasChildren: 'hasChildren',
                }"
                row-key="F_CompanyId"
                v-loading="loadings"
                element-loading-text="拼命加载中"
                element-loading-spinner="el-icon-loading"
                element-loading-background="rgba(0, 0, 0, 0.2)"
                @row-click="getRowInfos"
                highlight-current-row
                @current-change="rowChange"
                stripe
              >
                <el-table-column
                  type="index"
                  label="序号"
                  width="50"
                  align="center"
                ></el-table-column>
                <el-table-column
                  prop="F_CompanyId"
                  label="工程编号"
                ></el-table-column>
                <el-table-column
                  prop="F_ShortName"
                  label="工程名称"
                ></el-table-column>
                <el-table-column prop="F_Nature" label="工程类别" width="90">
                </el-table-column>

                <template slot="empty">
                  <img
                    style="width: 285px; height: 208px"
                    src="@/assets/img/undata.png"
                    alt=""
                  />
                  <div class="pageFlagText">暂时没有数据哦！</div>
                </template>
              </el-table>
            </div>
            <div style="height: 40px">
              <div style="position: absolute; right: 5px; bottom: 0">
                <el-button type="primary" @click="engineeringSave(rowD)"
                  >保存</el-button
                >
                <el-button
                  type="warning"
                  @click="dialogTableVisibleDivide == false"
                  >关闭</el-button
                >
              </div>
            </div>
          </div>
        </el-dialog>
      </div>
    </div>
  </div>
</template>

<script>
import {
  getGroupTeamByFid, //详情
  saveGroupTeam, //保存
  saveGroupTeamByEngineer, //签认保存
  getGroupTeamPageLists, //列表
  deleteGroupTeam, //删除
  commitGroupTeam, //提交
  getBaseDepartmentUser, //查人员
  getQualityDutyStationLists, //网格列表
  // getBaseCompanyList, //树结构
  getUserCompanyTreeList, //树结构
  getWorkProcessProjectList, //工程划分列表
} from "@/api/request.js";
import TableData from "@/components/stationProductionPage/HntManage/el-tables"; //主页面列表
import Pagination from "@/components/public/el-pagination"; //主页面分页
import publicForm from "@/components/public/el-form.vue"; //弹框form
import formJs from "./regexDetail.js"; //新增弹框配置项

export default {
  inject: ["reload"],
  name: "groupClassText",
  data() {
    return {
      name: "groupClassText",
      // 分页
      navigatepageNums: null, //是否显示分页
      queryCriteriaData: {},
      // 分页
      yj_add: null,
      yj_edit: null,
      yj_delete: null,
      yj_submit: null,
      yj_examine: null,
      radio: "待办",

      // 列表
      getList: {
        fCompanyid: "", // 左侧选中组织机构id
        fConstructtypeid: "", //查询条件 施工类型id 可不传
        page: 1, //页码
        pageSize: 20, //每页条数
        userId: "", // 查询待办或已办时传 列表页查询不传
        modelType: "", // 0代办 1已办 2表示列表页查询
      },
      fId: null, //当前行数据fId
      row: { fstatus: "" }, //选中行
      loading: false, //列表转载
      table_config: formJs.table_configText,
      tableData: [], //表格列表数据列表
      treelength: false, //左侧树显示隐藏
      // 列表

      // 弹框
      Sign: null,
      timeYMD: null, //当前日期
      btnShow: true,
      dialogTitle: "",
      loadingEditDialog: false, //弹框loading
      dialogEditVisible: false, //新增弹框是否显示
      FromShowTop: null,
      FromShowTextTop: formJs.FromShowTextTop, //信息编辑配置参数
      FromShowLookTop: formJs.FromShowLookTop, //信息编辑配置参数
      FromShowBottom: null,
      FromShowTextBottom: formJs.FromShowTextBottom, //信息编辑配置参数
      FromShowLookBottom: formJs.FromShowLookBottom, //信息编辑配置参数

      FromShow1: null,
      FromShowText1: formJs.FromShowText1, //信息编辑配置参数
      FromShowLook1: formJs.FromShowLook1, //信息查看配置参数
      formData: formJs.formData,
      recordfiles: [], //删除文件
      recordfiles1: [], //删除文件
      fSourcefileList: [],
      fSourcefileList1: [],
      saveData: {},
      getUserInitialList: [], //人员列表初始值
      // 质量网格弹框
      dialogEditVisibleGrid: false,
      loadingEditDialogGrid: false,
      table_configGrid: formJs.table_configGrid,
      tableDataGrid: [], //表格列表数据列表
      navigatepageNumsGrid: null, //是否显示分页
      queryCriteriaDataGrid: {},
      rowGrid: null,
      getListGrid: {
        fCompanyid: "", // 左侧选中组织机构id
        page: 1, //页码
        pageSize: 15, //每页条数
        userId: "", // 查询待办或已办时传 列表页查询不传
        modelType: "2", // 0代办 1已办 2表示列表页查询
        fQualitygridtype: "", // 质量网格类别
        fProjectposition: "", // 工程部位
      },
      // 质量网格弹框
      // 树选人
      dialogEditVisibleTree: false,
      loadingEditDialogTree: false,
      companyInfo: [], //公司树信息
      highlightBd: true,
      defaultProps: {
        children: "children",
        label: "fShortname",
      },
      departmentList: [], //部门
      num: null,
      personList: [], //人员列表新增
      checkboxGroup1: [],
      boys: require("@/assets/img/organization/boys.png"),
      girls: require("@/assets/img/organization/girls.png"),
      newData: null,
      treeText: {
        companyId: null,
        userId: null,
      },
      propText: null,
      candidate: null,
      // 树选人
      // 按工程划分新增
      loadings: false,
      dialogTableVisibleDivide: false,
      loadingDialogDivide: false,
      rowD: null,
      tableData5: [],
      fProjectpartid: null,
      fDnd: null,
      fProjectpart: null,
      // 按工程划分新增
      // 弹框
      userInfo: {}, //登录用户
    };
  },
  components: {
    TableData, //主页面列表
    Pagination, //分页
    publicForm, //表单
  },
  created() {},
  mounted() {
    this.userInfo = JSON.parse(sessionStorage.getItem("yjSmart-userInfo"));
    // console.log("userInfo", this.userInfo);
    // 质量网格弹框
    this.getListGrid = {
      fCompanyid: this.userInfo.companyId, // 左侧选中组织机构id
      // fCompanyid:"a1d978df-6665-4836-b892-5368af07dedd", // 左侧选中组织机构id
      page: 1, //页码
      pageSize: 15, //每页条数
      userId: "", // 查询待办或已办时传 列表页查询不传
      modelType: "2", // 0代办 1已办 2表示列表页查询
      fQualitygridtype: "", // 质量网格类别
      fProjectposition: "", // 工程部位
    };
    // 质量网格弹框
    this.getList = {
      fCompanyid: this.userInfo.companyId, // 左侧选中组织机构id
      userId: this.userInfo.userId, // 查询待办或已办时传 列表页查询不传
      page: 1, //页码
      pageSize: 20, //每页条数
      fConstructtypeid: "", //查询条件 施工类型id 可不传
      modelType: "0", // 0代办 1已办 不传或传空 表示列表页查询
    };
    this.getHeight();
    this.getData();
    this.yj_searchForm(this.getList);
    this.btnRole(this.name);
    this.getUser(this.userInfo.companyId);

    this.table_config.operation.cols = [
      {
        prop: "fstatus",
        type: "primary",
        handleRow: this.handleRow,
      },
    ];
    this.table_config.operation["specialClass"] = function (rowData) {
      var color = null;
      if (rowData == "已完成") {
        color = "green !important";
      } else if (rowData == "已打回") {
        color = "red !important";
      }
      return color;
    };
  },
  methods: {
    btnRole(name) {
      var btnList = [];
      var ModuleList = JSON.parse(sessionStorage.getItem("yjSmart-ModuleList"));
      if (ModuleList.length > 0) {
        ModuleList.map((item) => {
          if (item.fEncode == name) {
            btnList = item.modulebuttonList;
          }
        });
        var btnStr = [];
        btnList.map((item) => {
          btnStr.push(item.fEncode);
        });
        // this.yj_view = btnStr.includes("yj_view");
        this.yj_add = btnStr.includes("yj_add");
        this.yj_edit = btnStr.includes("yj_edit");
        this.yj_delete = btnStr.includes("yj_delete");
        this.yj_submit = btnStr.includes("yj_submit");
        this.yj_examine = btnStr.includes("yj_examine");
      } else {
        // this.yj_view = true;
        this.yj_add = true;
        this.yj_edit = true;
        this.yj_delete = true;
        this.yj_submit = true;
        this.yj_examine = true;
      }
    },

    modelType(e) {
     this.fId = "";
      this.row = "";
      if (e == "待办") {
        this.getList.modelType = "0";
        this.getList.userId = this.userInfo.userId;
      } else {
        this.getList.modelType = "1";
        this.getList.userId = this.userInfo.userId;
      }
      this.yj_searchForm(this.getList);
    },

    // 获取列表数据
    yj_searchForm(id) {
      this.row = { fstatus: "" }; //选中行
      this.loading = true;
      // if (id.fCompanyid == "") {
      getGroupTeamPageLists(id)
        .then((res) => {
          if (res.errcode == 0) {
            var that = this;
            that.loading = false;
            that.tableData = res.data.pageInfo.list;
            that.queryCriteriaData = res.data.pageInfo;
            that.navigatepageNums =
              that.queryCriteriaData.navigatepageNums.length;
          } else {
            this.$message.error("列表", res.msg);
            this.loading = false;
          }
        })
        .catch(() => {
          this.loading = false;
        });
      // } else {
      //   this.$message.error();
      // }
    },

    edit(title) {
      this.Sign = title;
      this.dialogTitle = title;
      this.recordfiles = [];
      this.recordfiles1 = [];
      this.FromShowTop = this.FromShowTextTop;
      this.FromShowBottom = this.FromShowTextBottom;
      this.FromShow1 = this.FromShowText1;

      if (title == "新增") {
        // this.loadingEditDialog = true; //弹框loading
        this.dialogEditVisible = true;
        this.btnShow = true;
        this.fSourcefileList = [];
        this.fSourcefileList1 = [];
        // this.getConcrete();
        var fDirectorreportfile = "fDirectorreportfile" + new Date().valueOf();
        var fQualityimagefile = "fQualityimagefile" + new Date().valueOf();
        this.formData = {
          fId: null, //传此表示修改  只有编辑中与已打回的状态可以进行修改
          userId: this.userInfo.userId, //当前登录人id
          userName: this.userInfo.realName, // 当前登录人名称
          fCompanyid: this.userInfo.companyId, // 所属标段id
          fCompanyname: this.userInfo.companyName, // 所属标段名称
          fProjectid: this.userInfo.projectId, // 所属项目id
          fProjectname: this.userInfo.projectName, // 所属项目名称
          fConstructtypeid: "", // 班组施工类型id
          fConstructtype: "", //班组施工类型
          fLaborteamid: "", //劳务队伍id
          fLaborteamname: "", //劳务队伍名称
          fTeamapproachdates: this.timeYMD, //班组进场时间
          fTeamphone: "", //班组长姓名/联系方式
          fQualitygridclassid: "", //首件工程隶属质量网格id
          fQualitygridclass: "", //首件工程隶属质量网格
          fFirstpartnameid: "", //首件部分项工程工程名称id
          fFirstpartname: "", //首件部分项工程工程名称
          fFirstpartlocation: "", //首件分项工程具体位置、桩号
          fFirstworkdates: "", //首件工程作业时间
          fChargeuserphone: "", //班组质量责任人电话
          fChargeuserid: "", //项目部质量负责人id
          fChargeusername: "", //项目部质量负责人姓名
          fInspectionresult: "", //首件工程质量验收情况
          fInspectorid: "", //检查签认项目监理工程师id
          fInspectorname: "", //检查签认项目监理工程师姓名
          fReporterid: this.userInfo.userId, //填报人id
          fReportername: this.userInfo.realName, //填报人姓名
          fReportdates: this.timeYMD, //填报日期
          fDirectorreportfile: fDirectorreportfile, //首件工程总结报告
          fQualityimagefile: fQualityimagefile, //首件工程相关影像
          fEngineersubid: "", //提交项目总工id
          fEngineersubname: "", //提交项目总工姓名

          fSignstatusid: "", //签认结果状态 1表示通过 2表示未通过
          fSignstatus: "", //签认结果
          fSignopinion: "", //签认说明
          fEngineerid: this.userInfo.userId, //项目总工id
          fEngineername: this.userInfo.realName, //项目总工姓名
          fSigndates: this.timeYMD, //签认时间
        };
      } else {
        this.btnShow = true;
        this.loadingEditDialog = true; //弹框loading
        this.dialogEditVisible = true;
        this.getConcrete(this.fId);
      }
    },
    // 获取详情
    getConcrete(id) {
      getGroupTeamByFid({ fId: id })
        .then((res) => {
          if (res.errcode == 0) {
            this.loadingEditDialog = false; //弹框loading
            this.formData = res.data.yjQmpMsGroupteamInformation;

            if (
              this.formData.fReportdates == "" ||
              this.formData.fReportdates == null
            ) {
              this.formData.fReportdates = this.timeYMD; //填报日期
            }
            if (
              this.formData.fTeamapproachdates == "" ||
              this.formData.fTeamapproachdates == null
            ) {
              this.formData.fTeamapproachdates = this.timeYMD; //填报日期
            }
            this.formData.fReportername = this.userInfo.realName; //填报人
            this.formData.fReporterid = this.userInfo.userId;

            this.formData.fEngineerid = this.userInfo.userId; //项目总工id
            this.formData.fEngineername = this.userInfo.realName; //项目总工姓名

            if (
              this.formData.fSigndates == "" ||
              this.formData.fSigndates == null
            ) {
              this.formData.fSigndates = this.timeYMD; //填报日期
            }

            this.fSourcefileList = res.data.fDirectorreportfilelist; //首件工程总结报告
            this.fSourcefileList1 = res.data.fQualityimagefilelist; //首件工程相关影像
          } else {
            this.loadingEditDialog = false; //弹框loading
            return this.$message.error(res.msg);
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 保存
    yj_saveForm(num) {
      if (num == 0) {
        if (
          this.$refs.publicForm0.submitForm() &&
          this.$refs.publicForm1.submitForm()
        ) {
          if (this.fSourcefileList.length != 0) {
            if (this.fSourcefileList.length != 0) {
              var recordfilesList = this.recordfiles.concat(this.recordfiles1);
              this.saveData = {
                fId: this.formData.fId, //传此表示修改  只有编辑中与已打回的状态可以进行修改
                userId: this.userInfo.userId, //当前登录人id
                userName: this.userInfo.realName, // 当前登录人名称
                fProjectname: this.formData.fProjectname, // 当前登录人项目名称
                fProjectid: this.formData.fProjectid, // 当前登录人项目ID
                fCompanyname: this.formData.fCompanyname, // 当前登录人标段名称
                fCompanyid: this.formData.fCompanyid, // 当前登录人标段ID
                fConstructtypeid: this.formData.fConstructtypeid, // 班组施工类型id
                fConstructtype: this.formData.fConstructtype, //班组施工类型
                fLaborteamid: this.formData.fLaborteamid, //劳务队伍id
                fLaborteamname: this.formData.fLaborteamname, //劳务队伍名称
                fTeamapproachdates: this.formData.fTeamapproachdates, //班组进场时间
                fTeamphone: this.formData.fTeamphone, //班组长姓名/联系方式
                fQualitygridclassid: this.formData.fQualitygridclassid, //首件工程隶属质量网格id
                fQualitygridclass: this.formData.fQualitygridclass, //首件工程隶属质量网格
                fFirstpartnameid: this.formData.fFirstpartnameid, //首件部分项工程工程名称id
                fFirstpartname: this.formData.fFirstpartname, //首件部分项工程工程名称
                fFirstpartlocation: this.formData.fFirstpartlocation, //首件分项工程具体位置、桩号
                fFirstworkdates: this.formData.fFirstworkdates, //首件工程作业时间
                fChargeuserphone: this.formData.fChargeuserphone, //班组质量责任人电话
                fChargeuserid: this.formData.fChargeuserid, //项目部质量负责人id
                fChargeusername: this.formData.fChargeusername, //项目部质量负责人姓名
                fInspectionresult: this.formData.fInspectionresult, //首件工程质量验收情况
                fInspectorid: this.formData.fInspectorid, //检查签认项目监理工程师id
                fInspectorname: this.formData.fInspectorname, //检查签认项目监理工程师姓名
                fReporterid: this.formData.fReporterid, //填报人id
                fReportername: this.formData.fReportername, //填报人姓名
                fReportdates: this.formData.fReportdates, //填报日期
                fDirectorreportfile: this.formData.fDirectorreportfile, //首件工程总结报告
                fQualityimagefile: this.formData.fQualityimagefile, //首件工程相关影像
                fEngineersubid: this.formData.fEngineersubid, //提交项目总工id
                fEngineersubname: this.formData.fEngineersubname, //提交项目总工姓名
                recordfiles: recordfilesList, //刪除文件合集
              };
              saveGroupTeam(this.saveData)
                .then((res) => {
                  if (res.errcode == 0) {
                    this.yj_searchForm(this.getList);
                    this.dialogEditVisible = false;
                    this.$message.success("新增成功");
                  } else {
                    this.$message.error(res.msg);
                    console.log("接口报错");
                  }
                })
                .catch((error) => {
                  console.log(error);
                });
            } else {
              this.$message.error("请检查'首件工程相关影像'是否上传");
            }
          } else {
            this.$message.error("请检查'首件工程总结报告'是否上传");
          }
        } else {
          console.log("error");
        }
      } else if (num == 1) {
        if (this.$refs.publicForm2.submitForm()) {
          var saveData2 = {
            fId: this.formData.fId,
            fSignstatusid: this.formData.fSignstatusid, //签认结果状态 1表示通过 2表示未通过
            fSignstatus: this.formData.fSignstatus, //签认结果
            fSignopinion: this.formData.fSignopinion, //签认说明
            fEngineerid: this.formData.fEngineerid, //项目总工id
            fEngineername: this.formData.fEngineername, //项目总工姓名
            fSigndates: this.formData.fSigndates, //签认时间
          };
          saveGroupTeamByEngineer(saveData2)
            .then((res) => {
              if (res.errcode == 0) {
                var that = this;
                that.yj_searchForm(that.getList);
                that.dialogEditVisible = false;
                that.$message.success("签认成功");
              } else {
                this.$message.error("res.errcode", res.msg);
                console.log("签认保存接口报错");
              }
            })
            .catch((error) => {
              console.log("签认保存接口报错", error);
            });
        } else {
          console.log("error");
        }
      }
    },

    // 提交
    SubmitText(id) {
      if (id != "" && id != null) {
        this.$confirm("是否继续提交?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.loading = true;
            commitGroupTeam({
              fId: id,
              userId: this.userInfo.userId,
              userName: this.userInfo.realName,
            })
              .then((res) => {
                if (res.errcode == 0) {
                  this.loading = false;
                  this.yj_searchForm(this.getList);
                  this.$message.success("提交成功");
                } else {
                  this.$message.error("提交失败", res.msg);
                  this.loading = false;
                }
              })
              .catch(() => {
                console.log("提交失败");
                this.loading = false;
              });
          })
          .catch(() => {
            this.$message("取消提交");
          });
      } else {
        return this.$message.error("请先选择需要提交的数据");
      }
    },

    // 删除
    rowDelete(id) {
      if (id != "" && id != null) {
        this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.loading = true;
            deleteGroupTeam({ fId: id })
              .then((res) => {
                if (res.errcode == 0) {
                  this.loading = false;
                  this.yj_searchForm(this.getList);
                  this.$message.success("删除成功");
                } else {
                  this.$message.error("删除失败", res.msg);
                  this.loading = false;
                }
              })
              .catch(() => {
                console.log("删除失败");
                this.loading = false;
              });
          })
          .catch(() => {
            this.$message("取消删除");
          });
      } else {
        return this.$message.error("请先选择需要删除的数据");
      }
    },

    // 获取页面容器高度
    getHeight() {
      var h = document.documentElement.clientHeight; //获取页面可见高度
      this.dialogHeight = h * 0.36 + "px";
    },
    // 点击查看
    yj_viewForm(row, label) {
      this.row = row;
      this.fId = row.fId;
      if (label == "班组施工类型") {
        this.editText(this.fId);
      }
    },

    // 查看
    editText(id) {
      this.FromShowTop = this.FromShowLookTop;
      this.FromShowBottom = this.FromShowLookBottom;
      this.FromShow1 = this.FromShowLook1;
      this.dialogTitle = "查看";
      this.Sign = "查看";
      this.btnShow = false;
      if (id != "" && id != null) {
        this.loadingEditDialog = true; //弹框loading
        this.dialogEditVisible = true;
        getGroupTeamByFid({ fId: id })
          .then((res) => {
            if (res.errcode == 0) {
              var that = this;
              that.loadingEditDialog = false;
              this.formData = res.data.yjQmpMsGroupteamInformation;
              this.fSourcefileList = res.data.fDirectorreportfilelist; //首件工程总结报告
              this.fSourcefileList1 = res.data.fQualityimagefilelist; //首件工程相关影像
            } else {
              this.$message.error("查看", res.msg);
              this.loadingEditDialog = false;
            }
          })
          .catch(() => {
            console.log("查看---详情接口报错");
            this.loadingEditDialog = false;
          });
      } else {
        return this.$message.error("请先选择需要查看的数据");
      }
    },

    // 驻拌合站试验人下拉框
    getUser(id) {
      getBaseDepartmentUser({ fCompanyid: id })
        .then((res) => {
          if (res.errcode == 0) {
            this.getUserInitialList = []; //人员列表初始值
            var getUser = {
              value: "",
              label: "",
            };
            var getUserList = []; //人员列表过滤后

            res.data.childList.map((v) => {
              if (v.fDepartmentId == this.userInfo.departmentId) {
                this.getUserInitialList = v.personList;
                this.getUserInitialList.map((v) => {
                  getUser = {
                    value: v.fRealname,
                    label: v.fRealname,
                  };
                  getUserList.push(getUser);
                });
              }
            });
            this.FromShowText1[2].options = getUserList;
          } else {
            this.$message.error(res.msg);
            console.log("部门管理-查询部门列表以及下属人员,接口报错");
          }
        })
        .catch((error) => {
          console.log("部门管理-查询部门列表以及下属人员", error);
        });
    },

    getData() {
      var time = new Date();
      const y = time.getFullYear();
      const m = (time.getMonth() + 1 + "").padStart(2, "0");
      const d = (time.getDate() + "").padStart(2, "0");
      this.timeYMD = `${y}-${m}-${d}`;
    },
    // 点击当前
    rowChange(val) {
      this.row = val;
      this.fId = val.fId;
    },

    // 刪除
    delteFile(file) {
      for (let index = 0; index < this.fSourcefileList.length; index++) {
        if (file.uid == this.fSourcefileList[index].uid) {
          if (this.fSourcefileList[index].atta == undefined) {
            this.recordfiles.push({
              fId: this.fSourcefileList[index].fId,
            });
          } else {
            this.recordfiles.push({
              fId: this.fSourcefileList[index].atta.fId,
            });
          }
          this.fSourcefileList.splice(index, 1);
        }
      }
    },
    delteFile1(file) {
      for (let index = 0; index < this.fSourcefileList1.length; index++) {
        if (file.uid == this.fSourcefileList1[index].uid) {
          if (this.fSourcefileList1[index].atta == undefined) {
            this.recordfiles1.push({
              fId: this.fSourcefileList1[index].fId,
            });
          } else {
            this.recordfiles1.push({
              fId: this.fSourcefileList1[index].atta.fId,
            });
          }
          this.fSourcefileList1.splice(index, 1);
        }
      }
    },
    inputChange(value, index, prop) {
      return value, index, prop;
    },
    selectChange(value, index, prop) {
      if (value == "内容不实，重新上报。") {
        this.formData.fSignstatusid = 2;
      } else if (value == "情况属实，信息确认。") {
        this.formData.fSignstatusid = 1;
      }
      return value, index, prop;
    },
    inputFocus(index, prop) {
      this.propText = prop;
      if (index == 2 && prop == "fQualitygridclass") {
        this.yj_searchFormGrid(this.getListGrid);
      } else if (index == 4 && prop == "fChargeusername") {
        this.candidate = "选择质量负责人";
        this.treeText.companyId = this.userInfo.companyId;
        this.treeText.userId = this.userInfo.userId;
        this.getBaseCompanyList(this.treeText);
      } else if (index == 5 && prop == "fInspectorname") {
        this.candidate = "选择监理工程师";
        this.treeText.companyId = this.userInfo.jlCompanyId;
        this.treeText.userId = this.userInfo.userId;
        this.getBaseCompanyList(this.treeText);
      } else if (index == 8 && prop == "fEngineersubname") {
        this.candidate = "选择项目总工";
        this.treeText.companyId = this.userInfo.companyId;
        this.treeText.userId = this.userInfo.userId;
        this.getBaseCompanyList(this.treeText);
      }
    },
    inputBlur(value, index, prop) {
      // 失去焦点触发
      if (index == 2 && prop == "fFirstpartname") {
        if (
          this.formData.fFirstpartname != "" &&
          this.formData.fFirstpartname != null &&
          this.formData.fFirstpartname != undefined
        ) {
          this.FromShowTop[3].placeholder = "请填写详细内容，没有则填'/'";
          this.FromShowTop[3].disabled = false;
        } else {
          this.FromShowTop[3].placeholder =
            "请先填写首件单位/分部/分项工程名称";
          this.FromShowTop[3].disabled = true;
          this.formData.fFirstpartlocation = "";
        }
      }
    },
    clickDialog(index, prop) {
      if (index == 2 && prop == "fFirstpartname") {
        this.getDataList();
      }
    },
    // 网格弹框
    rowChangeGrid(val) {
      this.rowGrid = val;
    },
    yj_searchFormGrid(id) {
      this.dialogEditVisibleGrid = true;
      this.loadingEditDialogGrid = true;
      getQualityDutyStationLists(id)
        .then((res) => {
          if (res.errcode == 0) {
            this.loadingEditDialogGrid = false;
            var that = this;
            that.loadingGrid = false;
            that.tableDataGrid = res.data.pageInfo.list;
            that.queryCriteriaDataGrid = res.data.pageInfo;
            that.navigatepageNumsGrid =
              that.queryCriteriaDataGrid.navigatepageNums.length;
            console.log(
              " that.navigatepageNumsGrid",
              that.navigatepageNumsGrid
            );
          } else {
            this.$message.error("网格列表", res.msg);
            this.loadingEditDialogGrid = false;
          }
        })
        .catch(() => {
          this.loadingEditDialogGrid = false;
        });
    },
    yj_saveFormGrid() {
      if (this.rowGrid == null) {
        this.$message.error("请先选择数据,再保存");
      } else {
        this.formData.fQualitygridclass = this.rowGrid.fProjectposition;
        this.formData.fQualitygridclassid = this.rowGrid.fId;
        this.dialogEditVisibleGrid = false;
      }
    },
    // 网格弹框
    // 树选人
    // 树结构
    getBaseCompanyList(data) {
      this.personList = [];
      this.departmentList = [];
      this.dialogEditVisibleTree = true;
      this.loadingEditDialogTree = true;
      getUserCompanyTreeList(data)
        .then((res) => {
          this.loadingEditDialogTree = false;
          if (res.errcode == 0) {
            this.companyTreeData = res.data.userCompanyTreeList;
            this.companyInfo = this.tranListToTreeData(
              res.data.userCompanyTreeList
            );
          } else {
            this.$message.error("获取组织机构单位", res.msg);
          }
        })
        .catch((error) => {
          console.log("获取组织机构单位,接口报错", error);
        });
    },
    tranListToTreeData(data) {
      let result = [];
      if (!Array.isArray(data)) {
        return result;
      }
      // 清除已存在的数据  重新赋值
      data.forEach((item) => {
        delete item.children;
      });

      let map = {};
      data.forEach((item) => {
        map[item.fCompanyid] = item;
      });

      data.forEach((item) => {
        let parent = map[item.fParentid];
        if (parent) {
          (parent.children || (parent.children = [])).push(item);
        } else {
          result.push(item);
        }
      });
      return result;
    },
    //根据树  调部门
    selectCompany(e) {
      this.getBaseDepartmentUser(e.fCompanyid);
    },
    // 部门管理-查询部门列表以及下属人员
    getBaseDepartmentUser(id) {
      getBaseDepartmentUser({ fCompanyid: id })
        .then((res) => {
          if (res.errcode == 0) {
            this.departmentList = res.data.childList;
            console.log("this.departmentList",this.departmentList);
          } else {
            this.$message.error("部门管理-查询部门列表以及下属人员", res.msg);
          }
        })
        .catch((error) => {
          console.log("部门管理-查询部门列表以及下属人员,接口报错", error);
        });
    },
    // 选择部门
    seletDepartment(e) {
      this.num = e.fDepartmentId;
      this.personList = [];
      let obj = {};
      // let reduce = [];
      this.personList = e.personList.reduce(function (item, next) {
        //item为没有重复id的数组，next为当前对象
        obj[next.fUserid] ? "" : (obj[next.fUserid] = true && item.push(next));
        return item;
      }, []);
    },
    selectRealname(e, data) {
      data.map((item) => {
        if (e == item.fUserid) {
          this.newData = item;
        }
      });
    },

    // 保存
    submitMember() {
      if (this.propText == "fChargeusername") {
        this.formData.fChargeuserid = this.newData.fUserid;
        this.formData.fChargeusername = this.newData.fRealname;
      } else if (this.propText == "fInspectorname") {
        this.formData.fInspectorid = this.newData.fUserid;
        this.formData.fInspectorname = this.newData.fRealname;
      } else if (this.propText == "fEngineersubname") {
        this.formData.fEngineersubid = this.newData.fUserid;
        this.formData.fEngineersubname = this.newData.fRealname;
      }
      this.dialogEditVisibleTree = false;
    },
    // 树选人
    //工程划分新增
    getRowInfos(e) {
      this.rowD = e;
    },
    getDataList() {
      this.dialogTableVisibleDivide = true;
      this.loadingDialogDivide = true;
      getWorkProcessProjectList({ companyId: this.userInfo.companyId })
        .then((res) => {
          if (res.errcode == 0) {
            var that = this;
            setTimeout(() => {
              this.loadingDialogDivide = false;
              that.tableData5 = this.tranListToTreeData1(
                res.data.workProcessProjectList
              );
              this.$nextTick(() => {
                var that = this;
                that.$refs.multipleTable.doLayout();
              });
            }, 200);
          } else {
            this.$message.error(res.msg);
            return false;
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },
    tranListToTreeData1(data) {
      let result = [];
      if (!Array.isArray(data)) {
        return result;
      }
      // 清除已存在的children 重新赋值
      data.forEach((item) => {
        delete item.children;
      });

      let map = {};
      data.forEach((item) => {
        map[item.F_CompanyId] = item;
      });

      data.forEach((item) => {
        let parent = map[item.F_ParentId];
        if (parent) {
          (parent.children || (parent.children = [])).push(item);
        } else {
          result.push(item);
        }
      });

      return result;
    },
    engineeringSave(data) {
      if (data.children == undefined) {
        this.rowD = data; //这是工程划分获得的数据  要什么打点取
        this.formData.fFirstpartname = data.F_TreeName; // 报验工程划分
        this.formData.fFirstpartnameid = data.F_EnCode; // 报验工程划分id
        this.$message.success("工程划分保存成功");
        this.dialogTableVisibleDivide = false;
        this.FromShowTop[3].placeholder = "请填写详细内容，没有则填'/'";
        this.FromShowTop[3].disabled = false;
        if (data.F_Nature != "位置/桩号") {
          this.formData.fFirstpartlocation = "/"; // 报验工程划分
        }
      } else {
        this.rowD = null;
        this.$message.warning("该条数据不符合要求");
      }
    },
    //工程划分新增
    // 多选方法
    selectionChange() {},
    // 排序方法
    sortChange() {},
  },
};
</script>

<style scoped lang="less">
.printTables {
  background: #fff;
  display: flex;
  justify-content: end;
  padding: 5px;
  margin-top: 10px;
}

.dialogBody {
  padding: 3px 20px;
  height: 80%;
  overflow-y: auto;
}

.baseTitle {
  /* border: 1px solid #0c204d; */
  border-bottom: 1px solid #0c204d;
  height: 30px;
  line-height: 30px;
  position: relative;
  padding-left: 15px;
}

.baseTitle::after {
  display: block;
  content: "";
  height: 30px;
  width: 5px;
  position: absolute;
  left: 0;
  top: 0;
  background: #0c204d;
}
/* 弹框 */
.publicForm {
  display: flex;
}
.publicForm .mouldForm /deep/ .el-form-item__content {
  margin-left: 170px !important;
}
.publicFormBox {
  width: 50%;
  height: 100%;
}
.closure /deep/ .el-input__suffix {
  left: 91%;
}
/* 树选人 */
.addMemberCheckBox {
  display: flex;
  .addMemberCheckTree {
    width: 30%;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(221, 221, 221, 1);
    box-sizing: border-box;

    .companyBox {
      height: 70%;
      box-sizing: border-box;
      overflow-y: auto;
    }

    .departmentBox {
      height: 30%;
      border-top: 0.5px solid rgba(221, 221, 221, 1);
      /* border: 1px solid red; */
      display: flex;
      flex-wrap: wrap;
      align-content: flex-start;
      overflow: hidden;
      overflow-y: auto;

      .departmentTitle {
        width: 77px;
        text-align: center;
        height: 40px;
        margin: 5px;
        // border: 1px solid green;
        border-radius: 8px;
        background: #d4daea;
        overflow: hidden;

        a {
          width: 100%;
          height: 100%;
          display: block;
          text-decoration: none;
        }
      }
    }
  }

  .selectMemberLeft {
    display: flex;
    align-items: center;
  }

  .addMemberCheckLeft {
    width: 70%;
    padding: 0 0 0 20px;
    border-top: 1px solid rgba(221, 221, 221, 1);
    border-bottom: 1px solid rgba(221, 221, 221, 1);
    border-right: 1px solid rgba(221, 221, 221, 1);

    .addMemberCheck {
      width: 150px;
      height: 64px;
      border-radius: 2px;
      display: flex;
      align-items: center;
      position: absolute;
      top: 0;
      left: 0;
    }
  }
}

.newlyAdded_btns {
  height: 8%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.addMemberCheck .MemberIcon {
  height: 62px;
  width: 64px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(241, 241, 241, 1);
}

.MemberIcon img {
  width: 37.81px;
  height: 39.38px;
  border-radius: 50%;
}

.MemberDetailInfos {
  position: relative;
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;

  .name {
    color: rgba(51, 51, 51, 1);
    font-size: 12px;
    height: 20px;
    line-height: 20px;
  }

  .hostName {
    color: rgba(128, 125, 125, 1);
    font-size: 12px;
    height: 20px;
    line-height: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.MemberIcon .name {
  color: rgba(51, 51, 51, 1);
  font-size: 12px;
  height: 20px;
  line-height: 20px;
}

.MemberIcon .hostName {
  color: rgba(128, 125, 125, 1);
  font-size: 12px;
  height: 20px;
  line-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activetext {
  color: rgba(197, 227, 255, 1);
  background: #2b5a9d;
}

// .MemberDetailInfo::after {
//   position: absolute;
//   width: 30px;
//   height: 30px;
//   display: block;
//   background: url("../../../assets/img/organization/yes.png") no-repeat;
//   background-size: 100% 100%;
//   right: 0;
//   top: 0;
// }

// .deleteUser {
//   position: absolute;
//   width: 22px;
//   height: 22px;
//   display: block;
//   background: url("../../../assets/img/organization/no.png") no-repeat;
//   background-size: 100% 100%;
//   right: 0;
//   top: 0;
// }

.samllDialogs {
  display: flex;
  margin: 0 20px;
  padding-top: 50px;
  .treeModule {
    flex: 1;
  }
}

.addMemberCheckLeft /deep/ .el-radio-button {
  display: inline-block;
  width: 150px;
  height: 64px;
  position: relative;
  margin: 8px;
  border-radius: 2px;
  overflow: hidden;
  /* border: 1px solid rgba(222, 222, 222, 1); */
}

.addMemberCheckLeft /deep/ .el-radio-button__inner {
  border: 1px solid rgba(222, 222, 222, 1);
  border-radius: 2px;
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
}

.addMemberCheckLeft /deep/ .el-radio-group {
  flex-wrap: wrap;
  font-size: 0;
  display: flex;
  /* flex-direction: column; */
}
/* 树选人 */

/* 弹框 */
</style>